Contact
The Contact module in the Scripting app allows you to access and manage contacts on the device. You can create, query, update, and delete contacts, as well as manage contact groups and containers.
Overview of Data Structures
Creating a Contact
- Either
givenNameorfamilyNameis required. - You may specify an optional
containerIdentifier. If not provided, the contact is added to the default container. - Always handle potential errors due to permission issues or invalid input.
Updating a Contact
identifieris required.- Only the provided fields will be updated; others remain unchanged.
Fetching Contacts
Fetch a Contact by Identifier
Fetch All Contacts
Fetch Contacts in a Container or Group
- Set
fetchImageDatatotrueonly if you need the contact's image data.
Deleting a Contact
Contact Container Management
Fetch All Containers
Get the Default Container Identifier
Container types:
unassignedlocalexchangecardDAV
Contact Group Management
Create a Contact Group
Fetch Groups
Delete a Group
Managing Contact and Group Relationship
Add Contact to a Group
Remove Contact from a Group
Example ContactInfo Structure
Important Notes
- All API operations can fail due to reasons such as lack of permission or invalid parameters. Always use
try-catch. - User permission is required to access contacts.
imageDatashould only be fetched if necessary to reduce memory usage.- Ensure the
identifieris valid when performing update or delete operations.
